package database.mysql.example;

import java.sql.*;



class Connect {
    public static void main(String ar[]) throws Exception{
    	
        //registering the driver
	    DriverManager.registerDriver(new com.mysql.jdbc.Driver());
	    
	    //Or you can write the below statement also
	    //Class.forName("com.mysql.jdbc.Driver").newInstance ();
	    
	    //establisn the conenction
		Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/sakila","root","mysql_123");
		System.out.println("Connection established");
		
	      //create the statement object
	      PreparedStatement pst = con.prepareStatement("select * from actor");
	  
	    
	          
	      ResultSet rs = pst.executeQuery();
	      
	      while(rs.next()) {
	          System.out.print(rs.getString(1)+"\t");
	          System.out.print(rs.getString(2)+"\t");
	          System.out.print(rs.getString(3)+"\n");
	      }

	      con.close();     



	}
}
		